// pages/oldadmin/oldadmin.js
var appUser = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    oldlist: [],
    loading: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
   
  },
  onShow(){
    this.getList()
  },

 // 根据删除老人
 delete(e) {
  console.log(e.currentTarget.dataset.id)
  wx.cloud.callFunction({
    name: "Oldman",
    data: {
      type: "delete",
      id: e.currentTarget.dataset.id
    }
  }).then(res => {
    wx.showToast({
      title: '删除成功'
    })
    this.getList()
  })
},

getList() {
  console.log(appUser.globalData.userOpenid)
wx.cloud.callFunction({
  name:"Oldman",
  data:{
    type:"select",
    opid:appUser.globalData.userOpenid
  }
}).then(res=>{
  console.log(res.result.data)
  this.setData({
    
    oldlist: res.result.data,
    loading: false
  })
})

 
},
toAdd() {
  wx.navigateTo({
    url: '../addman/addman',
  })
}
})